 /*****************************************************************************
 * (C) Copyright 2012 Atech-Automotive
 * FILE NAME:    hwa_a2dActions.h
 * DESCRIPTION:  Header file for a2dActions.c
 * DATE BEGUN:   
 * BY:           
 * PRODUCT NAME: 
 * APPLICATION:  
 * TARGET H/W:   
 * DOC REF:
 *****************************************************************************
 */

#ifndef hwa_a2dActions_h
#define hwa_a2dActions_h


/* #include */
#include "system.h"
#include "drv_a2d.h"
#include "hwa_inputs.h"
/* #define */
#define VBAT_MAX       (0xFF)   /* 20.4V for R1=100k & R2=16k with diode (0.75V) */

#define NORM           (171)    /* NORM = (33k/(100k+33k))*13.5V/5V*255 */                                                               
                                   
#define D_CORR         (0)     /* Assumed forward voltage Vf of diode: 0.75 V 
                                ** Set to '0' if no protection diode is fitted. 
                                */

#define LOW_V	    0
#define HI_V		1
/* typedef */ 
#define CH_S_VBAT_IN_AN        AIN1
#define CH_S_SSB_SW_3_IN_AN    AIN2
#define CH_S_SSB_SW_1_IN_AN    AIN6
#define CH_S_SSB_SW_2_IN_AN    AIN10


#define A2D_AVG_SIZE   (5)      /* size of A2D median buffer (must be odd) */



#define VBAT_POWER_DTC_DELAY_TIME_CNT  (25)  /* n * 10ms */

/* Variables */
#ifdef hwa_a2dActions_c
    volatile UINT8 vBatD;    /* filtered A2D value of Vbat (10ms sample rate) */
//    volatile UINT8 u8_vBatDCurrent;
    volatile UINT8 vWiperI;  /* filtered A2D value of VWiper (10ms sample rate) */
    BOOL F_noSwap;   
       
#else
    volatile extern UINT8 vBatD;
//    volatile extern UINT8 u8_vBatDCurrent;
    volatile extern UINT8 vWiperI;
    extern BOOL F_noSwap;
    
#endif

/* Function prototypes */
void hwa_a2d_v_iniA2dActions(void);
void hwa_a2d_v_a2dActions(void); 
UINT8 hwa_a2d_u8_normA2D(UINT8 value, UINT8 ref);
UINT8 hwa_a2d_u8_getFilteredA2D(UINT8 size, const UINT8 *const pArray);
UINT8 hwa_a2d__u8_getVbatDTCStatus(UINT8 cmd);


/***********************end of hwa_a2dActions.h***********************************/
#endif


/******************************************************************************
 Revision Notes:

For each change to this file, be sure to record:
1. Who made the change and when the change was made.
2. Why the change was made and the intended result.

  Date     By     Reason For Change
mm/dd/yy  XXX     -----------------

******************************************************************************/
